import redis
from flask_limiter import Limiter
from flask_limiter.util import get_remote_address

class RedisWrapper:
    def __init__(self):
        self.redis = None
    
    def init_app(self, app):
        self.redis = redis.Redis(
            host=app.config['REDIS_HOST'],
            port=app.config['REDIS_PORT'],
            db=app.config['REDIS_DB'],
            password=app.config['REDIS_PASSWORD'],
            decode_responses=True
        )

redis_conn = RedisWrapper()
limiter = Limiter(
    key_func=get_remote_address,
    storage_uri="redis://:123456@localhost:6379/1",  # 添加密码参数
    strategy="fixed-window"
)